package com.mnt.washio.utils;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.widget.Toast;

public class Statics {

	public static String TERMS_URL = "http://www.getwashio.com/terms";
	public static String FAQ_URL = "https://washio.zendesk.com/hc/en-us";
	public static String PRIVACY_POLICY_URL = "http://www.getwashio.com/privacy";
	public static String EULA_URL = "http://www.getwashio.com/eula";
	public static String WASHIO_WS_URL = "http://washiodev-washio.dotcloud.com/api/";
	public static String ADMIN_WS_URL = "http://admindev-washio.dotcloud.com/api/";
    public static String WASHIO_WS_URL_NEW = "http://washboard.washdv.com/api/";
    public static String ADMIN_WS_URL_NEW = "http://app.washdv.com/api/";
    
    public static final String MY_CARDIO_APP_TOKEN = "d27463254de34bd3b0cf9b94cd78bee7";
    public static final String PUBLISHABLE_KEY = "pk_PX1PQ6xdEREYbWfCWcoPZWmeRLMH2";
    
	
//	public static String NVN_ACCOUNT_ID = "BEqnIRgMlh";
	public static String WASHIO_PHONE = "+18862815686";
	
	public static void showToast(Context ctx, String txt) {
		Toast.makeText(ctx, txt, Toast.LENGTH_SHORT).show();
	}

	public static boolean isNetworkConnected(Context context) {
		ConnectivityManager cm = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo ni = cm.getActiveNetworkInfo();
		if (ni != null && ni.isConnected()) {
			return true;
		}
		return false;
	}
	
	public static boolean isEmailValid(String email) {
		return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
	}
	
	public static int PixelFromDp(Context context,int dp){
		return (int)(dp*context.getResources().getDisplayMetrics().density);
	}
	
	public static String getString(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getString(key);
		}
		return "";
	}
	
	public static int getInt(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getInt(key);
		}
		return 0;
	}
	
	public static double getDouble(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getDouble(key);
		}
		return 0;
	}
	
	public static long getLong(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getLong(key);
		}
		return 0;
	}
	
	public static boolean getBoolean(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getBoolean(key);
		}
		return false;
	}
	
	public static JSONObject getJSONObject(JSONObject json, String key) throws JSONException{
		if(json.has(key)){
			return json.getJSONObject(key);
		}
		return new JSONObject();
	}
}
